package com.rhm.dataStructure.Leetcode;/**
import	java.util.Scanner;
 * @Author:759057893@qq.com Lyz
 * @Date: ${Date} 23:53
 * @Description:
 **/

import javafx.scene.transform.Scale;

import java.util.Scanner;

/**
 *@Author:759057893@qq.com Lyz
 *@Date: 2020/2/19 23:53
 *@Description:
 **/
public class Code13 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
       while (sc.hasNext()){
            String s = sc.nextLine();
            System.out.println(roman(s));
        }
    }

    public static int roman(String s){
        int n =s.length();
        int a =0;
        for(int i =0;i<n;i++){
            switch (s.charAt(i)){
                case 'I': a =a+1; break;
                case 'V' : a = a + 5;break;
                case 'X' : a = a + 10;break;
                case 'L' : a = a + 50;break;
                case 'C' : a = a + 100;break;
                case 'D' : a = a + 500;break;
                case 'M' : a = a + 1000;break;
            }
            if(((s.charAt(i)=='V')||(s.charAt(i)=='X'))&&(s.charAt(i-1)=='I'))
                a = a-1*2;
            if(((s.charAt(i)=='L')||(s.charAt(i)=='C'))&&(s.charAt(i-1)=='X'))
                a = a-10*2;
            if(((s.charAt(i)=='D')||(s.charAt(i)=='M'))&&(s.charAt(i-1)=='C'))
                a = a-100*2;
        }
        return a;
    }
}
